using System;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;
using System.Drawing;
using SharpWind.Tools;

namespace SharpWind.Resources
{
	public class Shader : Resource
	{
		private Effect effect = null;

		public void SetConstant( string constant, Matrix value )
		{
			this.effect.SetValue( constant, value );
		}

		public void SetConstant( string constant, Color value )
		{
			this.effect.SetValue( constant, ColorValue.FromColor( value ) );
		}

		public int Begin()
		{
			return this.effect.Begin( 0 );
		}

		public void End()
		{
			this.effect.End();
		}

		public void BeginPass( int pass )
		{
			this.effect.BeginPass( pass );
		}

		public void EndPass()
		{
			this.effect.EndPass();
		}

		public override void Dispose()
		{
			SafeDispose.Dispose( this.effect );
		}

		internal Effect D3DEffect
		{
			get
			{
				return this.effect;
			}
			set
			{
				this.effect = value;
			}
		}

		public string Technique
		{
			set
			{
				this.effect.Technique = value;
			}
		}
	}
}
